#include <iostream>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;



struct edge{
	int stop,len;
};



int main(){
	int n,m,s,t,g,q;
	cin>>n>>m>>s>>t>>g>>q;
	s--;
	t--;
	int h[n],l[n];
	for(int i=0;i<n;i++)
		cin>>h[i]>>l[i];
	vector<edge> e[n];
	for(int i=0;i<m;i++){
		int start,stop,len;
		cin>>start>>stop>>len;
		start--;
		stop--;
		e[start].push_back({stop,len});
		e[stop].push_back({start,len});
	}
	
	queue<int> qq;
	int dis[n];
	bool inq[n];
	memset(dis,-1,sizeof(dis));
	memset(inq,false,sizeof(inq));
	
	dis[s] = 0;
	for(auto i:e[s]){
		dis[i.stop] = i.len;
		qq.push(i.stop);
		inq[i.stop] = true;
	}
//	for(int i=0;i<n;i++)
//		cout<<dis[i]<<" ";
//	cout<<endl;
	
	while(!qq.empty()){
		int now;
		now = qq.front();
		while(!qq.empty()  &&  now != t  &&  h[now]+dis[now]*q > l[now]){
			dis[now] = -1;
			qq.pop();
			now = qq.front();
		}
		if(qq.empty())
			break;
		qq.pop();
		
		
		for(auto i:e[now]){
			if(i.stop != t  &&  (dis[now]+i.len)*q+h[i.stop] > l[i.stop])
				continue;
			if(dis[i.stop] == -1){
				dis[i.stop] = dis[now]+i.len;
				if(!inq[i.stop]){
					qq.push(i.stop);
					inq[i.stop] = true;
				}
			}
			else if(dis[now]+i.len < dis[i.stop]){
				dis[i.stop] = dis[now]+i.len;
				if(!inq[i.stop]){
					qq.push(i.stop);
					inq[i.stop] = true;
				}
			}
		}
//		cout<<1<<endl;
	}
	
	
	if(dis[t] == -1)
		cout<<"wtnap wa kotori no oyatsu desu!";
	else
		cout<<dis[t];
	return 0;
}
